<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var str = prompt("请输入字符串");
      var uppercaseCount = 0;
      var lowercaseCount = 0;
      var digitCount = 0;
      var otherCount = 0;

      for (var i = 0; i < str.length; i++) {
        // 返回指定索引的字符
        var char = str.charAt(i);
        if (char >= "A" && char <= "Z") {
          uppercaseCount++;
        } else if (char >= "a" && char <= "z") {
          lowercaseCount++;
        } else if (char >= "0" && char <= "9") {
          digitCount++;
        } else {
          otherCount++;
        }
      }
      console.log(
        `大写${uppercaseCount}小写${lowercaseCount}数字${digitCount}其他${otherCount}`
      );
    </script>
  </body>
</html>
